package com.rizhov.gui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;

public class DoubleEdgeDialog extends JDialog {

    public boolean isRed = false;
    public int result = JOptionPane.CANCEL_OPTION;

    private final JPanel contentPanel = new JPanel();

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
	try {
	    DoubleEdgeDialog dialog = new DoubleEdgeDialog();
	    dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	    dialog.setVisible(true);
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }

    /**
     * Create the dialog.
     */
    public DoubleEdgeDialog() {
	setBounds(100, 100, 443, 147);
	getContentPane().setLayout(new BorderLayout());
	contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
	getContentPane().add(contentPanel, BorderLayout.CENTER);
	contentPanel.setLayout(null);

	ButtonGroup group = new ButtonGroup();
	JRadioButton rdbtnNewRadioButton = new JRadioButton("RED_EDGE");
	rdbtnNewRadioButton.addActionListener(new ActionListener() {
	    @Override
	    public void actionPerformed(ActionEvent e) {
		isRed = true;
	    }
	});
	rdbtnNewRadioButton.setBounds(10, 58, 109, 23);
	contentPanel.add(rdbtnNewRadioButton);
	group.add(rdbtnNewRadioButton);

	JRadioButton rdbtnNewRadioButton_1 = new JRadioButton("BLUE_EDGE");
	rdbtnNewRadioButton_1.addActionListener(new ActionListener() {
	    @Override
	    public void actionPerformed(ActionEvent e) {
		isRed = false;
	    }
	});
	rdbtnNewRadioButton_1.setSelected(true);
	rdbtnNewRadioButton_1.setBounds(10, 32, 109, 23);
	contentPanel.add(rdbtnNewRadioButton_1);
	group.add(rdbtnNewRadioButton_1);

	JLabel lblColorOfEditted = new JLabel("Color of editted edge: ");
	lblColorOfEditted.setBounds(10, 11, 134, 14);
	contentPanel.add(lblColorOfEditted);
	{
	    JPanel buttonPane = new JPanel();
	    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
	    getContentPane().add(buttonPane, BorderLayout.SOUTH);
	    {
		JButton okButton = new JButton("OK");
		okButton.addActionListener(new ActionListener() {
		    @Override
		    public void actionPerformed(ActionEvent e) {
			result = JOptionPane.OK_OPTION;
			setVisible(false);
		    }
		});
		okButton.setActionCommand("OK");
		buttonPane.add(okButton);
		getRootPane().setDefaultButton(okButton);
	    }
	    {
		JButton cancelButton = new JButton("Cancel");
		cancelButton.addActionListener(new ActionListener() {
		    @Override
		    public void actionPerformed(ActionEvent e) {
			result = JOptionPane.CANCEL_OPTION;
			setVisible(false);
		    }
		});
		cancelButton.setActionCommand("Cancel");
		buttonPane.add(cancelButton);
	    }
	}
    }
}
